short int convert_adc2temperature(short int ax, short int a0, short int a1, short int temp0, short int temp1);

#define TEMP0 10
#define TEMP1 60
#define ADC0 815
#define ADC1 397

const int analogOutPin=6;   //LED light control
unsigned char ledLight=0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  short int vad = analogRead(A0);
  vad = vad*0.5174;
  short int tempx = convert_adc2temperature(vad, ADC0, ADC1, TEMP0, TEMP1);
  ledLight=tempx*7;
  analogWrite(analogOutPin, ledLight);
}

short int convert_adc2temperature(short int ax, short int a0, short int a1, short int temp0, short int temp1)
{
  short int tempx;
  tempx = temp0 + (ax - a0) * (temp1 - temp0) / (a1 - a0);
  return tempx;
}

